﻿using System;
using System.Collections.Generic;


namespace Bibylon.BehafX.StateMachine.concept
{
    internal abstract class decorator : node
    {
        /// <summary>
        /// c'tor..
        /// </summary>
        public decorator ( string name, int nid, node parent )
            : base (name, nid, parent)
        {
            Attribuant = null;
        }

        /// <summary>
        /// @Copydoc - node::Category
        /// </summary>
        public override string Category
        {
            get { return "Decorator"; }
        }

        /// <summary>
        /// Block that needs to be decorated
        /// </summary>
        public node Attribuant  { get; set; }

        /// <summary>
        /// How this decorates the attached node?
        /// </summary>
        public int Policy { get; set; }

        /// <summary>
        /// ...
        /// </summary>
        public override List<node> Children
        {
            // Decorator has no children as well.
            get { return null; }
            protected set { throw new System.NotImplementedException();  }
        }

        /// <summary>
        /// @Copydoc - node::execute;
        /// </summary>
        /// <param name="agent"></param>
        /// <param name="any"></param>
        /// <returns></returns>
        internal override int execute(object agent, object any)
        {
            switch (Policy)
            {
                default:
                    // Decorator's acting depends on Policy...
                    throw new NotImplementedException();
                    break;

            }
           
        }

        /// <summary>
        /// @Copydoc - node::shutdown
        /// </summary>
        internal override void shutdown(object agent, bool applyToChildren = true)
        {
            base.shutdown(agent, applyToChildren);

            if ( applyToChildren && Attribuant != null )
            {
                Attribuant.shutdown(agent, applyToChildren);
            }
        }
    };
}
